package br.com.equus.entidade;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.envers.Audited;

import br.com.arquitetura.entidade.Entidade;

@Entity
@Table(name = "EQ_AGENDA", catalog = "EQUUS")
@Audited
public class Agenda extends Entidade<Integer> {

	private static final long serialVersionUID = 4041732843580427323L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID_AGENDA", unique = true, nullable = false)
	private Integer id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_EVENTO", referencedColumnName = "ID_TAREFA", nullable = false)
	private TipoTarefa tipoTarefa;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_USUARIO_RESP", referencedColumnName = "ID_USUARIO", nullable = false)
	private Usuario usuarioResp;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DT_INICIO", nullable = false)
	private Date dtInicio;

	@Column(name = "DSC_TAREFA", nullable = false,columnDefinition = "text")
	private String descricao;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DT_FIM", nullable = false)
	private Date dtFim;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "HR_INICIO", nullable = false)
	private Date hrInicio;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "HR_FIM", nullable = false)
	private Date hrFim;

	public Agenda() {
	}

	public Agenda(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public TipoTarefa getTipoTarefa() {
		return tipoTarefa;
	}

	public void setTipoTarefa(TipoTarefa tipoTarefa) {
		this.tipoTarefa = tipoTarefa;
	}

	public Usuario getUsuarioResp() {
		return usuarioResp;
	}

	public void setUsuarioResp(Usuario usuarioResp) {
		this.usuarioResp = usuarioResp;
	}

	public Date getDtInicio() {
		return dtInicio;
	}

	public void setDtInicio(Date dtInicio) {
		this.dtInicio = dtInicio;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Date getDtFim() {
		return dtFim;
	}

	public void setDtFim(Date dtFim) {
		this.dtFim = dtFim;
	}

	public Date getHrInicio() {
		return hrInicio;
	}

	public void setHrInicio(Date hrInicio) {
		this.hrInicio = hrInicio;
	}

	public Date getHrFim() {
		return hrFim;
	}

	public void setHrFim(Date hrFim) {
		this.hrFim = hrFim;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((descricao == null) ? 0 : descricao.hashCode());
		result = prime * result + ((dtFim == null) ? 0 : dtFim.hashCode());
		result = prime * result + ((dtInicio == null) ? 0 : dtInicio.hashCode());
		result = prime * result + ((hrFim == null) ? 0 : hrFim.hashCode());
		result = prime * result + ((hrInicio == null) ? 0 : hrInicio.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((tipoTarefa == null) ? 0 : tipoTarefa.hashCode());
		result = prime * result + ((usuarioResp == null) ? 0 : usuarioResp.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Agenda other = (Agenda) obj;
		if (descricao == null) {
			if (other.descricao != null)
				return false;
		} else if (!descricao.equals(other.descricao))
			return false;
		if (dtFim == null) {
			if (other.dtFim != null)
				return false;
		} else if (!dtFim.equals(other.dtFim))
			return false;
		if (dtInicio == null) {
			if (other.dtInicio != null)
				return false;
		} else if (!dtInicio.equals(other.dtInicio))
			return false;
		if (hrFim == null) {
			if (other.hrFim != null)
				return false;
		} else if (!hrFim.equals(other.hrFim))
			return false;
		if (hrInicio == null) {
			if (other.hrInicio != null)
				return false;
		} else if (!hrInicio.equals(other.hrInicio))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (tipoTarefa == null) {
			if (other.tipoTarefa != null)
				return false;
		} else if (!tipoTarefa.equals(other.tipoTarefa))
			return false;
		if (usuarioResp == null) {
			if (other.usuarioResp != null)
				return false;
		} else if (!usuarioResp.equals(other.usuarioResp))
			return false;
		return true;
	}

}
